import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

/* Layout */
import Layout from "@/layout";

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [{
        path: "/login",
        component: () =>
            import ("@/views/login/index"),
        hidden: true
    },

    {
        path: "/404",
        component: () =>
            import ("@/views/404"),
        hidden: true
    },

    {
        path: "/",
        component: Layout,
        redirect: "/dashboard",
        children: [{
            path: "dashboard",
            name: "Dashboard",
            component: () =>
                import ("@/pages/dashboard/index"),
            meta: { title: "首页大屏", icon: "aichong02" }
        }]
    },

    {
        path: "/statistics",
        component: Layout,
        meta: { title: "数据统计", icon: "aichong11" },
        children: [{
            path: "index",
            name: "statistics",
            component: () =>
                import ("@/pages/statistics/index"),
            meta: { title: "数据统计" }
        }]
    },

    {
        path: "/image",
        component: Layout,
        meta: { title: "图像模块", icon: "aichong06" },
        children: [{
                path: "index",
                name: "recognition",
                component: () =>
                    import ("@/pages/recognition/index"),
                meta: { title: "图像识别", icon: "aichong02" }
            },
            {
                path: "person",
                name: "recognition",
                component: () =>
                    import ("@/pages/recognition/person"),
                meta: { title: "人体识别", icon: "aichong04" }
            }

        ]
    },

    {
        path: "/config",
        component: Layout,
        meta: { title: "配置模块", icon: "aichong05" },
        children: [{
                path: "config",
                name: "Form",
                component: () =>
                    import ("@/pages/base/config"),
                meta: { title: "配置管理", icon: "aichong06" }
            },
            {
                path: "configCreate",
                hidden: true,
                name: "config_create",
                component: () =>
                    import ("@/pages/base/configCreate"),
                meta: { title: "配置添加" }
            },
            {
                path: "configMap",
                hidden: true,
                name: "config_map",
                component: () =>
                    import ("@/pages/base/configMap"),
                meta: { title: "地图" }
            },
            {
                path: "configRecognition",
                hidden: true,
                name: "config_recognition",
                component: () =>
                    import ("@/pages/base/configRecognition"),
                meta: { title: "图像识别" }
            },
            {
                path: "log",
                name: "Form",
                component: () =>
                    import ("@/pages/base/log"),
                meta: { title: "日志管理", icon: "aichong07" }
            },
            {
                path: "logCreate",
                hidden: true,
                name: "logcreate",
                component: () =>
                    import ("@/pages/base/logcreate"),
                meta: { title: "日志添加", icon: "aichong08" }
            }
        ]
    },

    {
        path: "/file",
        component: Layout,
        meta: { title: "文件模块", icon: "aichong15" },
        children: [{
                path: "file",
                name: "Form",
                component: () =>
                    import ("@/pages/base/file"),
                meta: { title: "文件管理", icon: "aichong10" }
            },
            {
                path: "fileCreate",
                hidden: true,
                name: "baseFile_create",
                component: () =>
                    import ("@/pages/base/fileCreate"),
                meta: { title: "新增文件" }
            },
            {
                path: "dataset",
                name: "Form",
                component: () =>
                    import ("@/pages/file/dataset"),
                meta: { title: "数据集管理", icon: "aichong11" }
            },
            {
                path: "datasetCreate",
                name: "Form",
                hidden: true,
                component: () =>
                    import ("@/pages/file/AddDataset"),
                meta: { title: "添加数据集", icon: "aichong12" }
            },
            {
                path: "datasetFile",
                name: "Form",
                component: () =>
                    import ("@/pages/file/datasetFile"),
                meta: { title: "数据集文件管理", icon: "aichong15" }
            },
            {
                path: "datasetFileCreate",
                hidden: true,
                name: "datasetFile_create",
                component: () =>
                    import ("@/pages/file/datasetFileCreate"),
                meta: { title: "添加数据集文件", icon: "eye-aichong14" }
            }
        ]
    },

    // {
    //     path: "/log",
    //     component: Layout,
    //     children: [{
    //             path: "log",
    //             name: "Form",
    //             component: () =>
    //                 import ("@/pages/base/log"),
    //             meta: { title: "日志模块", icon: "link" }
    //         },
    //         {
    //             path: "create",
    //             hidden: true,
    //             name: "logcreate",
    //             component: () =>
    //                 import ("@/pages/base/logcreate"),
    //             meta: { title: "日志添加", icon: "nested" }
    //         }
    //     ]
    // },

    {
        path: "/privilege",
        component: Layout,
        meta: { title: "权限模块", icon: "aichong25" },
        children: [{
                path: "privilege",
                name: "Form",
                component: () =>
                    import ("@/pages/base/privilege"),
                meta: { title: "权限管理", icon: "aichong15" }
            },
            {
                path: "privilegeCreate",
                hidden: true,
                name: "privilegecreate",
                component: () =>
                    import ("@/pages/base/privilegecreate"),
                meta: { title: "权限添加", icon: "aichong16" }
            },
            {
                path: "rolePrivilege",
                name: "Form",
                component: () =>
                    import ("@/pages/base/rolePrivilege"),
                meta: { title: "角色权限管理", icon: "aichong22" }
            },
            {
                path: "rolePrivilegeCreate",
                hidden: true,
                name: "rolePrivilege_create",
                component: () =>
                    import ("@/pages/base/rolePrivilegeCreate"),
                meta: { title: "角色ID创建", icon: "aichong18" }
            }
        ]
    },

    {
        path: "/role",
        component: Layout,
        meta: { title: "角色模块", icon: "aichong29" },
        children: [{
                path: "role",
                name: "Form",
                component: () =>
                    import ("@/pages/base/role"),
                meta: { title: "角色管理", icon: "aichong20" }
            },
            {
                path: "roleCreate",
                //  hidden: true,
                name: "role_create",
                component: () =>
                    import ("@/pages/base/roleCreate"),
                meta: { title: "角色创建", icon: "aichong25" }
            }
        ]
    },

    // {
    //     path: "/rolePrivilege",
    //     component: Layout,
    //     children: [{
    //             path: "rolePrivilege",
    //             name: "Form",
    //             component: () =>
    //                 import ("@/pages/base/rolePrivilege"),
    //             meta: { title: "角色权限模块", icon: "table" }
    //         },
    //         {
    //             path: "create",
    //             hidden: true,
    //             name: "rolePrivilege_create",
    //             component: () =>
    //                 import ("@/pages/base/rolePrivilegeCreate"),
    //             meta: { title: "角色ID创建", icon: "table" }
    //         }
    //     ]
    // },

    {
        path: "/user",
        component: Layout,
        meta: { title: "用户模块", icon: "aichong21" },
        children: [{
                path: "index",
                name: "user",
                component: () =>
                    import ("@/pages/base/user"),
                meta: { title: "用户管理", icon: "aichong24" }
            },
            {
                path: "userCreate",
                hidden: true,
                name: "user_create",
                component: () =>
                    import ("@/pages/base/userCreate"),
                meta: { title: "用户创建", icon: "aichong22" }
            },
            {
                path: "userRole",
                name: "Form",
                component: () =>
                    import ("@/pages/base/userRole"),
                meta: { title: "用户角色管理", icon: "aichong23" }
            },
            {
                path: "userRoleCreate",
                hidden: true,
                name: "userRole_create",
                component: () =>
                    import ("@/pages/base/userRoleCreate"),
                meta: { title: "用户角色创建", icon: "aichong24" }
            }
        ]
    },

    // {
    //     path: "/userRole",
    //     component: Layout,

    //     children: [{
    //             path: "userRole",
    //             name: "Form",
    //             component: () =>
    //                 import ("@/pages/base/userRole"),
    //             meta: { title: "用户角色模块", icon: "user" }
    //         },
    //         {
    //             path: "create",
    //             hidden: true,
    //             name: "userRole_create",
    //             component: () =>
    //                 import ("@/pages/base/userRoleCreate"),
    //             meta: { title: "用户角色创建", icon: "nested" }
    //         }
    //     ]
    // },

    {
        path: "/article",
        component: Layout,
        meta: { title: "技术板块", icon: "aichong25" },
        children: [{
                path: "index",
                name: "article",
                component: () =>
                    import ("@/pages/cms/article"),
                meta: { title: "技术文章", icon: "aichong04" }
            },
            {

                path: "KS",
                hidden: true,
                name: "greenhouse_KS",
                component: () =>
                    import ("@/pages/greenhouse/greenhousKS"),
                meta: { title: "数据分析", icon: "aichong32" }
            },
            {
                path: "greenHouse",
                name: "Form",
                component: () =>
                    import ("@/pages/greenhouse/greenHouse"),
                meta: { title: "精准农业", icon: "aichong27" }
            },
            {
                path: "greenhouseCreate",
                hidden: true,
                name: "greenhouse_create",
                component: () =>
                    import ("@/pages/greenhouse/GreenhouseCreate"),
                meta: { title: "项目创建", icon: "aichong28" }
            },
            {
                path: "articleCreate",
                hidden: true,
                name: "article_create",
                component: () =>
                    import ("@/pages/cms/articleCreate"),
                meta: { title: "文章创建", icon: "aichong29" }
            },
            {
                path: "category",
                name: "Form",
                component: () =>
                    import ("@/pages/cms/category"),
                meta: { title: "种类管理", icon: "aichong30" }
            },
            {
                path: "categoryCreate",
                hidden: true,
                name: "category_create",
                component: () =>
                    import ("@/pages/cms/categoryCreate"),
                meta: { title: "添加种类", icon: "nested" }
            },
            {
                path: "comment",
                name: "Form",
                component: () =>
                    import ("@/pages/cms/comment"),
                meta: { title: "评论管理", icon: "aichong31" }
            },
            {
                path: "commentCreate",
                hidden: true,
                name: "comment_create",
                component: () =>
                    import ("@/pages/cms/commentCreate"),
                meta: { title: "添加评论", icon: "example" }
            }
        ]
    },

    // {
    //     path: "/category",
    //     component: Layout,
    //     children: [{
    //             path: "category",
    //             name: "Form",
    //             component: () =>
    //                 import ("@/pages/cms/category"),
    //             meta: { title: "种类模块", icon: "nested" }
    //         },
    //         {
    //             path: "create",
    //             hidden: true,
    //             name: "category_create",
    //             component: () =>
    //                 import ("@/pages/cms/categoryCreate"),
    //             meta: { title: "添加种类模块", icon: "nested" }
    //         }
    //     ]
    // },
    // {
    //     path: "/comment",
    //     component: Layout,
    //     children: [{
    //             path: "comment",
    //             name: "Form",
    //             component: () =>
    //                 import ("@/pages/cms/comment"),
    //             meta: { title: "评论模块", icon: "example" }
    //         },
    //         {
    //             path: "create",
    //             hidden: true,
    //             name: "comment_create",
    //             component: () =>
    //                 import ("@/pages/cms/commentCreate"),
    //             meta: { title: "添加评论", icon: "example" }
    //         }
    //     ]
    // },

    // {
    //     path: "/dataset",
    //     component: Layout,
    //     children: [{
    //             path: "dataset",
    //             name: "Form",
    //             component: () =>
    //                 import ("@/pages/file/dataset"),
    //             meta: { title: "训练数据", icon: "form" }
    //         },
    //         {
    //             path: "create",
    //             name: "Form",
    //             hidden: true,
    //             component: () =>
    //                 import ("@/pages/file/AddDataset"),
    //             meta: { title: "训练数据文件", icon: "form" }
    //         }
    //     ]
    // },

    // {
    //     path: "/datasetFile",
    //     component: Layout,
    //     children: [{
    //             path: "datasetFile",
    //             name: "Form",
    //             component: () =>
    //                 import ("@/pages/file/datasetFile"),
    //             meta: { title: "数据集文件模块", icon: "eye-open" }
    //         },
    //         {
    //             path: "create",
    //             hidden: true,
    //             name: "datasetFile_create",
    //             component: () =>
    //                 import ("@/pages/file/datasetFileCreate"),
    //             meta: { title: "添加数据集文件", icon: "eye-open" }
    //         }
    //     ]
    // },

    {
        path: "/application",
        component: Layout,
        meta: { title: "应用模块", icon: "aichong32" },
        children: [{
                path: "application",
                name: "Form",
                component: () =>
                    import ("@/pages/greenhouse/application"),
                meta: { title: "应用管理", icon: "aichong12" }
            },
            {
                path: "applicationCreate",
                hidden: true,
                name: "application_create",
                component: () =>
                    import ("@/pages/greenhouse/ApplicationCreate"),
                meta: { title: "应用创建", icon: "nested" }
            },
            {

                path: "create",
                hidden: true,
                name: "greenhouse_create",
                component: () =>
                    import ("@/pages/greenhouse/GreenhouseCreate"),
                meta: { title: "项目创建", icon: "nested" }
            },
            {

                path: "interface",
                name: "Form",
                component: () =>
                    import ("@/pages/greenhouse/interface"),
                meta: { title: "接口管理", icon: "aichong14" }
            },
            {
                path: "interfaceCreate",
                name: "interface_create",
                hidden: true,
                component: () =>
                    import ("@/pages/greenhouse/AddInterface"),
                meta: { title: "接口创建", icon: "password" }
            }
        ]
    },

    // {
    //     path: "/interface",
    //     component: Layout,
    //     children: [{

    //             path: "interface",
    //             name: "Form",
    //             component: () =>
    //                 import ("@/pages/greenhouse/interface"),
    //             meta: { title: "接口管理", icon: "aichong14" }
    //         },
    //         {
    //             path: "interfaceCreate",
    //             name: "interface_create",
    //             hidden: true,
    //             component: () =>
    //                 import ("@/pages/greenhouse/AddInterface"),
    //             meta: { title: "接口创建", icon: "password" }
    //         }
    //     ]
    // },

    // {
    //     path: "/greenHouse",
    //     component: Layout,
    //     meta: { title: "农业技术", icon: "link" },
    //     children: [{
    //             path: "greenHouse",
    //             name: "Form",
    //             component: () =>
    //                 import ("@/pages/greenhouse/greenHouse"),
    //             meta: { title: "绿色农业模块", icon: "link" }
    //         },
    //         {
    //             path: "create",
    //             hidden: true,
    //             name: "greenhouse_create",
    //             component: () =>
    //                 import ("@/pages/greenhouse/GreenhouseCreate"),
    //             meta: { title: "项目创建", icon: "nested" }
    //         }
    //     ]
    // },

    // {
    //     path: "/interface",
    //     component: Layout,
    //     children: [{
    //             path: "interface",
    //             name: "Form",
    //             component: () =>
    //                 import ("@/pages/greenhouse/interface"),
    //             meta: { title: "接口模块", icon: "password" }
    //         },
    //         {
    //             path: "create",
    //             name: "interface_create",
    //             hidden: true,
    //             component: () =>
    //                 import ("@/pages/greenhouse/AddInterface"),
    //             meta: { title: "接口创建", icon: "password" }
    //         }
    //     ]
    // },

    {
        path: "/message",
        component: Layout,
        meta: { title: "咨询管理", icon: "aichong16" },
        children: [{
            path: "message",
            name: "Form",
            component: () =>
                import ("@/pages/greenhouse/message"),
            meta: { title: "咨询管理" }
        }]
    },
    {
        path: "/module",
        component: Layout,
        meta: { title: "模型模块", icon: "aichong06" },
        children: [{
                path: "module",
                name: "Form",
                component: () =>
                    import ("@/pages/greenhouse/module"),
                meta: { title: "模型管理", icon: "aichong11" }
            },
            {
                path: "create",
                name: "moduleCreate",
                hidden: true,
                component: () =>
                    import ("@/pages/greenhouse/moduleCreate"),
                meta: { title: "新增模型", icon: "aichong16" }
            },
            {
                path: "publish",
                name: "modulePublish",
                component: () =>
                    import ("@/pages/greenhouse/modulePublish"),
                meta: { title: "训练数据", icon: "aichong12" }
            },
            {
                path: "train",
                name: "moduleTrain",
                component: () =>
                    import ("@/pages/greenhouse/moduleTrain"),
                meta: { title: "图像识别", icon: "aichong11" }
            }
        ]
    },

    // 404 page must be placed at the end !!!
    { path: "*", redirect: "/404", hidden: true }
];

const createRouter = () =>
    new Router({
        // mode: 'history', // require service support
        scrollBehavior: () => ({ y: 0 }),
        routes: constantRoutes
    });

const router = createRouter();

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
    const newRouter = createRouter();
    router.matcher = newRouter.matcher; // reset router
}

export default router;